﻿{% extends "base.html" %}
{% block scripts %}
{% endblock %}
{% block content %}
    <h1>Друзья</h1>


    <ul class="tabs_list friends_tabs">
        <li class="item"><a href="/friends/">Все друзья</a><span class="bg"></span></li>
        <li class="item item_current"><a href="/online_friends/">Друзья онлайн</a><span class="bg"></span></li>
        {% if request.user.invitations_to.count > 0 %}
            <li class="item"><a href="/possible_friends/">Заявки в друзья</a><span class="bg"></span></li>
        {% endif %}
    </ul>
    {% if friends.object_list %}
    <ul class="paging">
        {% if friends.has_previous %}
            <li><a href="/users/{{ friends.previous_page_number }}/"><img class="icon" src="/media/images/icon_arrow_2.gif" width="11" height="5"></a></li>
        {% endif %}

        {% for page in friends.paginator.page_range %}
            {% if page == friends.number %}
                <li class="item item_current">{{ page }}</li>
            {% else %}
                <li class="item"> <a href="/users/{{ page }}/">{{ page }}</a></li>
            {% endif %}
        {% endfor %}

        {% if friends.has_next %}
            <li><a href="/users/{{ friends.next_page_number }}/"><img class="icon" src="/media/images/icon_arrow_1.gif" width="11" height="5"></a></li>
        {% endif %}
    </ul>
    {% endif %}


    <ul class="info_list_1 friends_list">
        {% for friend in friends.object_list %}
            <li class="list_item {% if forloop.first %}list_item_first{% endif %}">
                <img class="pic"
                        {% if friend.user_info.avatar %}
                     src="{{ friend.user_info.avatar.url }}"
                        {% if friend.user_info.avatar.width > friend.user_info.avatar.height %}
                     width="79"
                        {% else %}
                     height="79"
                        {% endif %}
                        {% else %}
                     src="/media/images/nophoto.jpg/"
                     width="79" height="79"
                        {% endif %}/>
                <div class="item_base">
                    <dl class="info">
                        <dt>Имя:</dt>
                        <dd><a href="/profile/{{ friend.id }}/">{{ friend.user_info.last_name }} {{ friend.user_info.first_name }}</a></dd>
                        {% if friend.companies.count > 0 %}
                                    <dt>Компании:</dt>
                                        <dd>
                                            {% for company in friend.companies.all %}
                                                {% if forloop.counter0 < 3 %}
                                                    <a href="/company/{{ company.id }}/">{{ company.name }}</a>
                                                {% endif %}
                                            {% endfor %}
                                            <a href="/user_companies/{{ friend.id }}/">Всего: {{ friend.companies.count }}</a>
                                        </dd>
                                    {% endif %}
                    </dl>
                </div>
                <ul class="options">
                    <li class="item"><a href="#">Написать сообщение</a></li>
                    <li class="item"><a href="/friends/cancel/{{ friend.id }}/">Удалить</a></li>
                </ul>
            </li>
        {% endfor %}
    </ul>

    {% if friends.object_list %}
    <ul class="paging">
        {% if friends.has_previous %}
            <li><a href="/users/{{ friends.previous_page_number }}/"><img class="icon" src="/media/images/icon_arrow_2.gif" width="11" height="5"></a></li>
        {% endif %}

        {% for page in friends.paginator.page_range %}
            {% if page == friends.number %}
                <li class="item item_current">{{ page }}</li>
            {% else %}
                <li class="item"> <a href="/users/{{ page }}/">{{ page }}</a></li>
            {% endif %}
        {% endfor %}

        {% if friends.has_next %}
            <li><a href="/users/{{ friends.next_page_number }}/"><img class="icon" src="/media/images/icon_arrow_1.gif" width="11" height="5"></a></li>
        {% endif %}
    </ul>
    {% endif %}
{% endblock %}